﻿// -----------------------------------------------------------------------
// <copyright file="AppController.cs" company="Support">
// TODO: Update copyright text.
// </copyright>
// -----------------------------------------------------------------------

namespace SupportSystemDB
{
    using System;

    /// <summary>
    /// The Main Core of Application.
    /// </summary>
    public class AppController : IDisposable
    {
        /// <summary>
        /// Instance of the singleton pattern.
        /// </summary>
        private static AppController instance = new AppController();

        /// <summary>
        /// Entities governing the database connection.
        /// </summary>
        private SupportEntities supportDB = new SupportEntities();

        /// <summary>
        /// Quotes Controller Instance
        /// </summary>
        private QuoteController quotes;

        /// <summary>
        /// Member Controller Instance
        /// </summary>
        private MemberController members;

        /// <summary>
        /// Events Controller Instance
        /// </summary>
        private EventController events;

        /// <summary>
        /// Message Controller Instance
        /// </summary>
        private MessageController messages;

        /// <summary>
        /// Prevents a default instance of the <see cref="AppController" /> class from being created.
        /// </summary>
        private AppController()
        {
            this.quotes = new QuoteController( this.supportDB );
            this.members = new MemberController( this.supportDB );
            this.events = new EventController( this.supportDB );
            this.messages = new MessageController( this.supportDB );
        }

        /// <summary>
        /// Gets the singleton instance.
        /// </summary>
        public static AppController Instance
        {
            get { return AppController.instance; }
        }

        /// <summary>
        /// Gets the quotes.
        /// </summary>
        /// <value>The quotes.</value>
        public QuoteController Quotes
        {
            get { return this.quotes; }
        }

        /// <summary>
        /// Gets the members.
        /// </summary>
        /// <value>The members.</value>
        public MemberController Members
        {
            get { return this.members; }
        }

        /// <summary>
        /// Gets the events.
        /// </summary>
        /// <value>The events.</value>
        public EventController Events
        {
            get { return this.events; }
        }

        /// <summary>
        /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
        /// </summary>
        public void Dispose()
        {
            this.supportDB.Dispose();
        }
    }
}
